package com.fresh.fresh.service.lmpI;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fresh.fresh.dao.User;
import com.fresh.fresh.mapper.UserMapper;
import com.fresh.fresh.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Override
    public User login(User user) {
        LambdaQueryWrapper<User> res = new LambdaQueryWrapper<>();
        res.eq(User::getUsername, user.getUsername());
        res.eq(User::getPassword, user.getPassword());

        User data = this.baseMapper.selectOne(res);
        if (data != null) {
            return data;
        } else {
            return null;
        }
    }

    @Override
    public void register(User user) {
        this.baseMapper.insert(user);
    }




}
